package com.base.cn.platform.os.entity.exam.question;

/**
 * 试题难度
 *
 * @author s.li
 * @date 2019/01/03
 */
public enum QuestionDifficulty {
    SIMPLE("简单",1),
    SECONDARY("中等",2),
    DIFFICULTY("困难",3);

    private String difficultyName;
    private int type;

    QuestionDifficulty(String difficultyName,int type){
        this.difficultyName = difficultyName;
        this.type = type;
    }

    public static int getType(String difficultyName){
        for(QuestionDifficulty typeEnum : QuestionDifficulty.values()){
            if(typeEnum.getDifficultyName().equals(difficultyName.trim())){
                return typeEnum.getType();
            }
        }
        return 0;
    }

    public static QuestionDifficulty getQuestionTypeEnum(String difficultyName){
        for(QuestionDifficulty typeEnum : QuestionDifficulty.values()){
            if(typeEnum.getDifficultyName().equals(difficultyName)){
                return typeEnum;
            }
        }
        return null;
    }


    public static String getDifficultyName(int type){
        for(QuestionDifficulty typeEnum : QuestionDifficulty.values()){
            if(typeEnum.getType()==type){
                return typeEnum.getDifficultyName();
            }
        }
        return null;
    }

    public static QuestionDifficulty getQuestionTypeEnum(int type){
        for(QuestionDifficulty typeEnum : QuestionDifficulty.values()){
            if(typeEnum.getType()==type){
                return typeEnum;
            }
        }
        return null;
    }


    public String getDifficultyName() {
        return difficultyName;
    }

    public void setDifficultyName(String difficultyName) {
        this.difficultyName = difficultyName;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }
}
